﻿namespace STLTypeVisualizer
{
	using System;
	using VisualGDBExpressions;

	internal class GccMapFilter : GccTreeFilter
	{
		static string[] textArray1 = new string[] { "std::map<", "std::multimap<" };
		public GccMapFilter() : base(textArray1)
		{
		}

		protected override IExpression CreateNodeExpression(IExpressionEvaluator evaluator, string treeNodeExpr, ref int idx)
		{
			string str = treeNodeExpr + "->_M_value_field.";
			IExpression expr = evaluator.CreateExpression(str + "first", true);
			if (expr == null)
			{
				string[] textArray1 = new string[] { "((__typeof__(", treeNodeExpr, "->_M_valptr()))&(", treeNodeExpr, "->_M_storage->_M_storage))->" };
				str = string.Concat(textArray1);
				expr = evaluator.CreateExpression(str + "first", true);
			}
			if (expr == null)
			{
				return null;
			}
			string str2 = expr.Value.ToString();
			expr = evaluator.CreateExpression(str + "second", true);
			if (expr == null)
			{
				return null;
			}
			ExpressionValue value2 = expr.Value;
			expr = evaluator.CreateExpression(str.TrimEnd(new char[] { '.', '-', '>' }), false);
			if (expr == null)
			{
				return null;
			}
			StaticExpressionFilter filter1 = new StaticExpressionFilter(expr);
			filter1.ShortNameOverride = str2;
			filter1.ValueOverride = value2;
			return filter1;
		}

		protected override string ExpandLabel =>
			"[展开以填充std::map]";
	}

	internal class ClangMapFilter : ClangTreeFilter
	{
		static string[] textArray1 = new string[] { "std::__1::map<", "std::__1::multimap<" };
		public ClangMapFilter() : base(textArray1)
		{
		}

		protected override IExpression CreateNodeExpression(IExpressionEvaluator evaluator, string treeNodeExpr, ref int idx)
		{
			string str = treeNodeExpr + "->__value_->__cc.";
			IExpression expr = evaluator.CreateExpression(str + "first", true);
			if (expr == null)
			{
				return null;
			}
			string str2 = expr.Value.ToString();
			expr = evaluator.CreateExpression(str + "second", true);
			if (expr == null)
			{
				return null;
			}
			ExpressionValue value2 = expr.Value;
			expr = evaluator.CreateExpression(str.TrimEnd(new char[] { '.', '-', '>' }), false);
			if (expr == null)
			{
				return null;
			}
			StaticExpressionFilter filter1 = new StaticExpressionFilter(expr);
			filter1.ShortNameOverride = str2;
			filter1.ValueOverride = value2;
			return filter1;
		}

		protected override string ExpandLabel =>
			"[展开以填充std::map]";
	}
}

